function ajax(url) {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.responseType = 'json';
        xhr.onload = function () {
            if (this.status === 200) {
                resolve(this.response);
            } else {
                reject(new Error(this.statusText));
            }
        };
        xhr.send();
    });
}

ajax('./../package.json').then(function (res) {
    console.log('res', res);
}).catch(err => {
    console.log('err', err);
});

ajax('./../package---err.json').then(function (res) {
    console.log('res', res);
}).catch(err => {
    console.log('err', err);
})